<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@page import="cn.com.dhcc.app.core.CoreEnv.CoreInitCtx"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.max {
  color: red
}

.min {
  color: #bac9d2
}
</style>
<meta charset="utf-8" />
<title>${appname}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<script type="text/javascript">
	var taskValue = '${param.taskId}';
	var dateValue = '${param.statDate}';
	
	$(document).ready(function() {
		restoreContent();
		findMaxMin();
		/* $(window.parent.document.getElementById('content')).load(function(){
			this.height='400px';
		}); */
	});
	
	function restoreContent() {
		if(dateValue != '') {
			$('#Date').val(dateValue);
		}
		
		if(taskValue != '') {
			$('#task').val(taskValue);
		}
	}
	
	function search(form) {
		$(form).appendPagerParaStr();
		return true;
	}
	
	function findMaxMin() {
		var values1 = $('table td.value1').map(function(index, td) {
		    return $(td).text();
		}).get();
		
		var values2 = $('table td.value2').map(function(index, td) {
		    return $(td).text();
		}).get();
		
		var max1 = Math.max.apply(null, values1);
	    var min1 = Math.min.apply(null, values1);
		$('table td.value1').each(function(i, td) {
			$(td).toggleClass('max', +$(td).text() === max1);
		    $(td).toggleClass('min', +$(td).text() === 0);
		});
		
		var max2 = Math.max.apply(null, values2);
	    var min2 = Math.min.apply(null, values2);
	    $('table td.value2').each(function(i, td) {
			$(td).toggleClass('max', +$(td).text() === max2);
		    $(td).toggleClass('min', +$(td).text() === 0);
		});
	}
</script>

</head>
<style type="text/css">
th {
	word-break: keep-all;
	white-space: nowrap;
}
</style>
<body>
	<div class="main-container" id="main-container">
		<div class="main-container-inner">
			<div class="main-content" style="margin-left: 0px;">

				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb">
						<li><i class="icon-home home-icon"></i> 首页</li>
						<li class="active">综合统计</li>
						<li class="active">任务日历</li>
					</ul>
				</div>

				<div class="page-content">
					<div class="tabbable">
						<ul class="nav nav-tabs" id="myTab">
							<li><a href="${ctx}/stat/task_calendar.do"> 任务日历图 </a></li>

							<li class="active"><a hre="#"> 表格查看 </a></li>
						</ul>

					</div>

					<div class="tab-content" id="myTabContent">

						<div class="widget-box ">
							<form id="searchForm" class="form-search"
								action="${ctx}/stat/taskCalenda_info_list.do" method="post"
								onsubmit="return search(this)">
								<div class="widget-header widget-header-flat">
									<span> 选择任务: </span> <select id="task" name="taskId"  style="width: 200px;">
										<option value="all" select="selected">全部任务</option>
										<c:forEach var="task" items="${tasks}" varStatus="stc">
											<option value="${task.id}">${task.taskName}</option>
										</c:forEach>
										
									</select> <span>选择时间 :</span>

									<%
											Calendar cal = Calendar.getInstance();
											cal.add(Calendar.DATE, -1);
											String date = new SimpleDateFormat("yyyy-MM-dd").format(cal
													.getTime());
											String month = new SimpleDateFormat("yyyy-MM")
													.format(cal.getTime());
											String year = new SimpleDateFormat("yyyy").format(cal.getTime());
										%>

									<input type="hidden" name="day" id="hidden_day"
										value="<%=date%>"> <input type="hidden" name="month"
										id="hidden_month" value="<%=month%>"> <input
										type="hidden" name="year" id="hidden_year" value="<%=year%>">



									<span class="input-icon input-icon-right"> <input
										type="text" class="form-control form-input" id="Date"
										name="statDate" value="<%=date%> "
										onfocus="WdatePicker({onpicked:function(){},dateFmt:'yyyy-MM-dd',maxDate:'%y-%M-{%d-1}'});" />
										<i class="icon-calendar blue pointer"
										onclick="javascript:$('#Date').focus();"></i>
									</span>
									
									<div class="widget-toolbar no-border" >
											<button class="btn btn-xs btn-primary" >
												统计</button>&nbsp;&nbsp;&nbsp;
									</div>
								</div>
							</form>
						</div>

						<div class="hr hr12 hr-dotted"></div>

						<div class="table-responsive">
							<table id="sample-table-1"
								class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center">序号</th>
										<th class="center">任务名称</th>
										<th class="center">数据分类</th>
										<th class="center">同步频次(次)</th>
										<th class="center">数据量(条)</th>
										<th class="center">统计时间</th>
										<!-- <th class="center">更新时间</th> -->

									</tr>
								</thead>

								<tbody>
									<c:forEach var="vo" items="${_data}" varStatus="varStatus">
										<tr>

											<td align="center">${varStatus.index + 1}</td>
											<td align="center">${vo.taskName}</td>
											<td align="center">${vo.dataCataName}</td>
											<td align="center" class="value1">${vo.total}</td>
											<td align="center" class="value2">${vo.dataSize}</td>
											<td align="center"><fmt:formatDate
													value="${vo.statDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>

										</tr>
									</c:forEach>
								</tbody>
							</table>
							<jsp:include page="/WEB-INF/view/common/pg.jsp">
								<jsp:param value="${ctx}/stat/taskCalenda_info_list	.do"
									name="url" />
								<jsp:param value="${_total}" name="total" />
								<jsp:param value="${_urlpara}" name="urlpara" />
							</jsp:include>
						</div>

					</div>


				</div>

			</div>
		</div>
	</div>
</body>
</html>
